<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:p="http://primefaces.org/ui"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="/pages/home.xhtml">
	<ui:define name="title">
		<h:outputText value="#{text.titPrograma}" />
	</ui:define>
	<ui:define name="js">
	</ui:define>
	<ui:define name="content">
		<p:watermark value="mm/aaaa" for="inicioPrevisto"></p:watermark>
		<p:watermark value="mm/aaaa" for="fimPrevisto"></p:watermark>
		<p:fieldset id="fieldSetPrograma" legend="#{text.lgdProgramaForm}" collapsed="true"
			toggleable="true" binding="#{programaController.fieldSetPrograma}">
			
			<h:inputHidden id="programaId" value="#{programaController.selectedPrograma.id}" />
			
			<h:panelGrid id="pnlFields" columns="3">
				<h:outputLabel for="cod" value="#{text.lblProgramaCod}" />
				<p:inputMask id="cod" required="true" size="50" maxlength="40"
					requiredMessage="#{message.requiredProgramaCodigo}"
					value="#{programaController.selectedPrograma.codigo}" mask="?9999999999" placeHolder=""/>
				<p:message for="cod" />
			     
			    <h:outputLabel for="macroObjetivo" value="MacroObjetivo" />  
        		  <p:selectOneMenu id="macroObjetivo" value="#{programaController.selectedPrograma.macroObjetivo}"  converter="macroObjetivoConverter">  
            			<f:selectItem itemLabel="Selecione..." itemValue="" />  
            			<f:selectItems value="#{programaController.macroObjetivos}" var="macroObjetivo" itemLabel="#{macroObjetivo.descMacroObjetivo}" itemValue="#{macroObjetivo}"/>  
        		 </p:selectOneMenu> 
				<p:message for="macroObjetivo" />

			    <h:outputLabel for="objetivo" value="Objetivo" />
			    <p:inputTextarea id="objetivo" rows="6" cols="36" value="#{programaController.selectedPrograma.objetivo}"/>    
				<p:message for="objetivo" />

			    <h:outputLabel for="denominacao" value="Denominação" />
			    <p:inputText id="denominacao" size="50" value="#{programaController.selectedPrograma.denominacao}"/>    
				<p:message for="denominacao" />
					

			    <h:outputLabel for="orgao" value="Orgão " />  
        		  <p:selectOneMenu id="orgao" value="#{programaController.selectedPrograma.orgao}"  converter="orgaoConverter">  
            			<f:selectItem itemLabel="Selecione..." itemValue="" />  
            			<f:selectItems value="#{programaController.orgaos}" var="orgao" itemLabel="#{orgao.descOrgao}" itemValue="#{orgao}"/>  
        		 </p:selectOneMenu> 
				<p:message for="orgao" />

			    <h:outputLabel for="publicoAlvo" value="Público Alvo" />
			    <p:inputText id="publicoAlvo" size="50" value="#{programaController.selectedPrograma.publicoAlvo}"/>    
				<p:message for="publicoAlvo" />

			    <h:outputLabel for="naturezas" value="Natureza" />
			        <p:selectOneRadio id="naturezas" value="#{programaController.selectedPrograma.natureza}">  
			            <f:selectItem itemLabel="Contínua" itemValue="1" />  
			            <f:selectItem itemLabel="Temporária" itemValue="2" />  
			        </p:selectOneRadio>  
				<p:message for="naturezas" />
  


			    <h:outputLabel for="inicioPrevisto" value="Início Previsto" />
			    <p:inputMask id="inicioPrevisto" mask="99/9999" value="#{programaController.selectedPrograma.inicioPrevisto}"/>    
				<p:message for="inicioPrevisto" />

			    <h:outputLabel for="fimPrevisto" value="Término Previsto" />
			    <p:inputMask id="fimPrevisto" mask="99/9999" value="#{programaController.selectedPrograma.finalPrevisto}"/>    
				<p:message for="fimPrevisto" />
			

			    <h:outputLabel for="gestor" value="Gestor" />
			    <p:inputText id="gestor" size="50" value="#{programaController.selectedPrograma.gestor}"/>    
				<p:message for="gestor" />
			

			    <h:outputLabel for="multisetorial" value="Multisetorial" />
			        <p:selectOneRadio id="multisetorial" value="#{programaController.selectedPrograma.multisetorial}">  
			            <f:selectItem itemLabel="Sim" itemValue="1" />  
			            <f:selectItem itemLabel="Não" itemValue="0" />  
			        </p:selectOneRadio>  
				<p:message for="multisetorial" />


			</h:panelGrid>


			<p:separator />

			<p:commandButton id="btnNew" value="#{text.btnNew}"
				icon="ui-icon-document" actionListener="#{programaController.newPrograma}"
				immediate="true" update=":frmContent:fieldSetPrograma"
				onclick="grdPrograma.unselectAllRows();clearRadioDataTable();clearDataTableFilter(grdPrograma);" />
			<p:commandButton id="btnSave" value="#{text.btnSave}"
				icon="ui-icon-disk"
				update=":frmContent:fieldSetPrograma, :frmContent:grdPrograma"
				actionListener="#{programaController.savePrograma}"
				oncomplete="clearDataTableFilter(grdPrograma);"
				process=":frmContent:fieldSetPrograma" />
			<p:commandButton id="btnDelete" value="#{text.btnDelete}"
				icon="ui-icon-trash" onclick="dialogDelete.show()"
				binding="#{programaController.btnDelete}" disabled="true" global="false"/>
			<p:confirmDialog id="dlgConfirmDelete" widgetVar="dialogDelete"
				closable="true" severity="info" appendToBody="true"
				header="#{text.dlgConfirm}" message="#{message.confirmDelete}"
				width="400">
				<p:commandButton id="btnConfirmDelete"
					actionListener="#{programaController.deletePrograma}"
					value="#{text.btnConfirm}" icon="ui-icon-check"
					oncomplete="dialogDelete.hide();clearDataTableFilter(grdPrograma);"
					update=":frmContent:fieldSetPrograma, :frmContent:grdPrograma" />
				<p:commandButton id="btnDeclineDelete" onclick="dialogDelete.hide()"
					value="#{text.btnCancel}" icon="ui-icon-cancel" global="false"/>
			</p:confirmDialog>

		</p:fieldset>

		<p:spacer height="25" />

		<p:dataTable id="grdPrograma" var="programa"  paginatorPosition="bottom"
			value="#{programaController.programaDataModel}" widgetVar="grdPrograma"
			emptyMessage="#{text.grdEmpty}"
			selection="#{programaController.selectedPrograma}" paginator="true"
			rows="10" rowsPerPageTemplate="10,25,50"
			paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
			style="width:600px;" sortBy="#{programa.codigo}" filterEvent="enter">

			<p:ajax event="rowSelect" update=":frmContent:fieldSetPrograma"
				listener="#{programaController.selectPrograma}" />

			<p:column selectionMode="single" style="width:18px" />
			<p:column id="colProgramaDesc" headerText="#{text.lblProgramaCod}" sortBy="#{programa.codigo}" filterBy="#{programa.codigo}">
				<h:outputText value="#{programa.codigo}"/>
			</p:column>
			<p:column id="colProgramaDenominacao" headerText="Denominação"
				sortBy="#{programa.denominacao}" filterBy="#{programa.denominacao}">
				<h:outputText value="#{programa.denominacao}" />
			</p:column>
		</p:dataTable>


	</ui:define>
</ui:composition>

</html>